package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

/**
 * 子表单的ES枚举值
 * @author 梁鲁江
 * @version v1.0
 * @date 2019/8/13 14:37
 * @since v1.0
 */
@Getter
public enum SubEsAliasEnum {
    /**
     * EsAlias
     * 注：
     * 1. 选择产品比自定义子表单数量多是因为代码中已经占用了该数量，目前前端已限制住可新增的自定义数量；
     * 2.其自定义的数量依然按照自定义表单数量为准
     * 3.现在最大值只允许这么限定，暂时不放大
     */
    TEXT("text", "enum.subEsAlias.description.text", 19, 21, 2, 8, 2),
    NUM("num", "enum.subEsAlias.description.num", 10, 51, 0, 0, 1),
    LONG("long", "enum.subEsAlias.description.num", 0, 0, 0, 0, 0),
    ADDRESS("address", "enum.subEsAlias.description.address", 2, 2, 0, 1, 0),
    GEO("geo", "enum.subEsAlias.description.geo", 2, 2, 0, 0, 0),
    DATE("date", "enum.subEsAlias.description.date", 10, 40, 0, 0, 0),
    FILE("file", "enum.subEsAlias.description.file", 10, 10, 0, 0, 0),
    ARRAY("array", "enum.subEsAlias.description.array", 20, 20, 0, 0, 0 ),
    /**
     * 现在地址和定位的存储无差别
     */
    LOCATION("location","enum.esAlias.description.address",4, 0,0, 0, 0),
    ;

    SubEsAliasEnum(String esAlias, String description, Integer max, Integer selectProductNum, Integer contactPhoneNum, Integer singleSubFormNum, Integer switchTextNum) {
        this.esAlias = esAlias;
        this.description = description;
        this.max = max;
        this.selectProductNum = selectProductNum;
        this.contactPhoneNum = contactPhoneNum;
        this.singleSubFormNum = singleSubFormNum;
        this.switchTextNum = switchTextNum;
    }

    /**
     * 字段
     */
    private String esAlias;
    /**
     * 字段描述
     */
    private String description;
    /**
     * 最大个数
     */
    private Integer max;

    /**
     * 选择产品中子表单的数量
     */
    private Integer selectProductNum;

    /**
     * 联系电话里字段的数量
     */
    private Integer contactPhoneNum;
    /**
     * 孤独子表单里字段的数量
     */
    private Integer singleSubFormNum;
    /**
     * 开关+文本显示里字段的数量
     */
    private Integer switchTextNum;

    public String getDescription() {
        return I18nMessageUtil.getMessage(description);
    }

    /**
     * 前端子字段数量限制
     * @return
     */
    public static List<SubEsAliasEnum> getEsSubAliasList() {
        return Arrays.asList(SubEsAliasEnum.TEXT, SubEsAliasEnum.NUM, SubEsAliasEnum.ARRAY, SubEsAliasEnum.FILE, SubEsAliasEnum.DATE, SubEsAliasEnum.GEO,  SubEsAliasEnum.ADDRESS);
    }
}
